#include "TerrainTester.h"

using namespace CAIG;
using namespace DKGL;

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

#ifdef _DEBUG
	#pragma comment(lib, "dkgl_d.lib")
#else
	#pragma comment(lib, "dkgl.lib")
#endif

TerrainTester::TerrainTester()
{

}

bool TerrainTester::init()
{
	return (CWin::init());
}

void TerrainTester::OnCreate()
{
	CreateDKGLContext(hDC);
	
	Scene *scenePtr = g_SceneMgr.createScene("Scene");
	m_pCamera = scenePtr->createCamera("Camera");
	m_pCamera->bindViewport(g_ViewportMgr.getViewportPtr());



	m_FT.putOnTerrain(&m_terrain, Vector3::ZERO);

	
}


void TerrainTester::OnPaint()
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	g_SceneMgr.render();
}


void TerrainTester::OnSize(WORD width, WORD height)
{
	g_ViewportMgr.getViewportPtr()->onSize(
		intRect2D(0, 0, static_cast<int>(width), static_cast<int>(height)),
		DKGL::DefaultVpSizer());
}
	
void TerrainTester::OnTime()
{
}
	
void TerrainTester::KeyDown()
{
}

int WINAPI WinMain (HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	PSTR szCmdLine, int iCmdShow)
{
	Log::clear();
	TerrainTester app;
	if (app.init())
	{	
		app.go();
	}
	return 0;
}